/**
 * 
 */
package robotninja.driver.asctec.test;

import robotninja.driver.asctec.util.crc16.CRC16JavaImp;
import robotninja.driver.asctec.util.crc16.ICRC16;
import android.test.suitebuilder.annotation.SmallTest;
import junit.framework.TestCase;

/**
 * @author dav
 * 
 */
public class CRC16 extends TestCase {

	ICRC16 crc16;

	/*
	 * (non-Javadoc)
	 * 
	 * @see junit.framework.TestCase#setUp()
	 */
	protected void setUp() throws Exception {
		super.setUp();

		crc16 = new CRC16JavaImp();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see junit.framework.TestCase#tearDown()
	 */
	protected void tearDown() throws Exception {
		super.tearDown();
	}

	/**
	 * Test method for
	 * {@link robotninja.driver.asctec.util.crc16.CRC16JavaImp#crc16(int[])}.
	 */
	@SmallTest
	public void testCrc16() {

		// IMU Raw Data
		int data[] = { 0x7E, 0xFF, 0xFF, 0xFF, 0xA0, 0xFF, 0xA6, 0x01, 0x6E,
				0xFC, 0x93, 0x01, 0x2B, 0x02, 0xE4, 0x01, 0xD9, 0x2B, 0x26,
				0x2E, 0x90, 0x15, 0x44, 0x7A, 0x3C, 0x37, 0x00, 0x00, };
		assertEquals(crc16.crc16(data), 0x693A);

		// Current way
		data = new int[] { 00, 01, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
		assertEquals(crc16.crc16(data), 0xAAB1);

		// GPS Data
		data = new int[] { 0xD4, 0x96, 0x28, 0xF4, 0xF5, 0xA6, 0xCB, 0xE5,
				0x84, 0x27, 0x0C, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00,
				00, 00, 00, 0xC6, 00, 00, 00, 0xC6, 00, 00, 0x40, 0xC6, 00, 00,
				00, 00, 00, 00, 00, 00, 00, 00 };
		assertEquals(crc16.crc16(data), 0x9729);
	}
}
